/*
 * fat.c
 *
 *  Created on: 25/09/2011
 *      Author: MaxiG
 */

#include "fat.h"

t_FAT32BootSector readBootSector( uint8_t buffer[] )
{
	if(sizeof(t_FAT32BootSector) > sizeof(buffer))
		perror("ERROR: El buffer es menor al bootsector.");
	t_FAT32BootSector bs;
	memcpy(&bs,&buffer,sizeof(t_FAT32BootSector));
	return bs;
}

t_FSInformationSector readInformationSector( uint8_t buffer[] )
{
	if((sizeof(t_FAT32BootSector)+sizeof(t_FSInformationSector)) > sizeof(buffer))
		perror("ERROR: El buffer es menor al bootsector.");
	t_FAT32BootSector bs;
	t_FSInformationSector is;
	bs = readBootSector(buffer);
	memcpy(&is,&(buffer[bs.FSInfo]),sizeof(t_FSInformationSector));
	return is;
}
 void FATTableInit(t_FAT32BootSector bootsector, uint8_t buffer[])
 {
	 uint32_t FAT[(bootsector->sectorsPerFAT)/bootsector->secPerClus];
	 memcpy(&FAT,&buffer[bootsector->reservedSecCnt * bootsector->bytesPerSec],sizeof(FAT));
 }

int main (void)
{
	FILE *file ;
	int *buffer;
	file = fopen("","r");
	//fread(buffer,sizeof(uint8_t),sizeof(file),file);

	fclose(file);
	return 0;
}
